﻿package mortal.game.scene3D.display3d.text3d.dynamicText3d
{
    import baseEngine.core.*;
    import frEngine.shader.*;
    import frEngine.shader.filters.*;
    import frEngine.shader.filters.fragmentFilters.*;

    public class Text3DFragmentFilter extends FragmentFilter
    {
        private var _textBg0:Texture3D;

        public function Text3DFragmentFilter(param1:Texture3D)
        {
            super([param1]);
            this._textBg0 = param1;
            return;
        }// end function

        override public function setRegisterParams(param1:Program3dRegisterInstance) : void
        {
            param1.getParamByName("{textBg0}", false).value = this._textBg0;
            return;
        }// end function

        override public function get programeId() : String
        {
            return "textFragmentFilter0";
        }// end function

        override public function createVertexCode(param1:Program3dRegisterInstance, param2:int) : String
        {
            var _loc_3:* = new Array();
            _loc_3.push(new ToBuilderInfo("va0", FilterName.UV, false, 2));
            _loc_3.push(new ToBuilderInfo("vf0", FilterName.V_UvOriginalPos, false, 1));
            var _loc_4:String = "mov           vf0         \t va0        \t\t\t\t\n";
            _loc_4 = param1.toBuild(_loc_4, _loc_3);
            return _loc_4;
        }// end function

        override public function createFragmentUvCoord(param1:Program3dRegisterInstance) : String
        {
            var _loc_2:* = new Array();
            var _loc_3:String = "";
            _loc_2.push(new ToBuilderInfo("ft0", FilterName.F_UVPostion, false, 1));
            var _loc_4:* = FilterName.V_UvOriginalPos;
            _loc_3 = _loc_3 + ("mov           ft0         \t " + _loc_4 + "        \t\t\t\t\t\t\t\n");
            _loc_3 = _loc_3 + "mul           ft0.y\t\t\tft0.y      \t\t\t{v_textRate}.x\t\t\t\n";
            _loc_3 = _loc_3 + "add           ft0.y\t\t\t{v_textRate}.y      \tft0.y\t\t\t\t\t\n";
            _loc_3 = param1.toBuild(_loc_3, _loc_2);
            return _loc_3;
        }// end function

        override public function createFragmentColor(param1:Program3dRegisterInstance, param2:Boolean) : String
        {
            var _loc_3:* = new Array();
            _loc_3.push(new ToBuilderInfo("fs0", "{textBg0}", false, 1, this._textBg0));
            var _loc_4:* = FilterName.F_UVPostion;
            var _loc_5:String = "";
            _loc_5 = _loc_5 + "kil\t\t\t{v_textRate}.z\t\t\n";
            _loc_5 = _loc_5 + ("tex\t\t\t{output}   \t" + _loc_4 + ".xy    " + getSmapleString("fs0", this._textBg0.format, param2, Texture3D.MIP_NONE, "nearest") + "\t\n");
            _loc_5 = _loc_5 + "mul        {output}   \t{output}  \t\t \t\t{v_textRate}.w\t\t\n";
            _loc_5 = _loc_5 + "sub\t\t\tft0.x\t   \t\t{output}.w\t\t\t\t{fcConst1}.y\t\t\n";
            _loc_5 = _loc_5 + "kil\t\t\tft0.x\t   \t\t\t\t\t\t\t\t\t\t\t\t\t\n";
            _loc_5 = param1.toBuild(_loc_5, _loc_3);
            return _loc_5;
        }// end function

    }
}
